package com.it.mapper;

import com.it.pojo.Brand;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface BrandMapper {

    /**
     * 查询所有
     * @return
     */

    @Select("select * from tb_brand;")
    @ResultMap("brandResultMap")  //别名
    List<Brand> selectAll();

    @Insert("insert into tb_brand value(null,#{brandName},#{companyName},#{ordered},#{description},#{status})")
    void add(Brand brand);

    void deleteByIds(@Param("ids") int[] ids);

    //分页查询
    @ResultMap("brandResultMap")
    @Select("select * from tb_brand limit #{begin},#{size} ;")
    List<Brand> selectByPage(@Param("begin") int begin,@Param("size") int size);
    //查询总记录数
    @Select("select count(*) from tb_brand;")
    int selectTotalCount();

    //分页条件查询
    @ResultMap("brandResultMap")
    List<Brand> selectByPageAndCondition(@Param("begin") int begin,@Param("size") int size,@Param("brand")Brand brand);

    //根据条件查询总记录数
    int selectTotalCountByCondition(Brand brand);
}
